package com.weiyi.mashangzhu.Landlord.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.weiyi.mashangzhu.Landlord.Bean.AccountBean;
import com.weiyi.mashangzhu.R;

import java.util.List;

/**
 * Created by win7 on 2017/9/25.
 */

public class AccountAdapter extends BaseAdapter {
    List<AccountBean.DataBean> list;
    Context context;

    public AccountAdapter(List<AccountBean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_account, null);
            viewHolder.account = (TextView) convertView.findViewById(R.id.account);
            convertView.setTag(viewHolder);
        }
        viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.account.setText(list.get(position).getAlipayAccount().substring(0,4)+"****"+list.get(position).getAlipayAccount().substring(8));
        return convertView;
    }

    class ViewHolder {
        TextView account;
    }
}
